package com.bw.controller;

import com.alibaba.fastjson.JSON;
import com.bw.entity.User;
import com.bw.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.servlet.http.HttpServletRequest;
import java.util.Arrays;
import java.util.List;

//@Controller
public class LoginControllerDEL {

    @Autowired
    UserMapper userMapper;

    @RequestMapping("/login.do")
    public String login(HttpServletRequest request){

        String name = request.getParameter("name");
        System.out.println("name--" + name);
        String password = request.getParameter("password");
        System.out.println("password--" + password);
        return "success";
    }

    @RequestMapping("/login2.do")
    public String login2(@RequestParam("userName") String name, String password,@RequestParam(defaultValue = "10") Integer age){

        System.out.println("name--" + name);
        System.out.println("password--" + password);

        System.out.println("age--" + age);
        return "success";
    }

    @RequestMapping("/login3.do")
    public String login3(User user, Model model){

        System.out.println("user---" + JSON.toJSONString(user));
        // 给jsp页面填充数据
        model.addAttribute("name",user.getName());

        return "success";// 页面
    }
}
